package com.atguigu.math;

import org.junit.jupiter.api.Test;

public class TestMath {
    @Test
    public void test(){
        //求一个数的绝对值
        System.out.println(Math.abs(5));
        System.out.println(Math.abs(-5));
    }
    @Test
    public void test2(){
        System.out.println(Math.ceil(2.6));//3.0  ceil天花板，向上取整
        System.out.println(Math.floor(2.6));//2.0  floor地板，向下取整
        System.out.println(Math.round(2.6));//3    round周围，四舍五入
    }
    @Test
    public void test3(){
        System.out.println(Math.ceil(2.4));//3.0  ceil天花板，向上取整
        System.out.println(Math.floor(2.4));//2.0  floor地板，向下取整
        System.out.println(Math.round(2.4));//2    round周围，四舍五入
    }

    @Test
    public void test4(){
        System.out.println(Math.ceil(2.5));//3.0  ceil天花板，向上取整
        System.out.println(Math.floor(2.5));//2.0  floor地板，向下取整
        System.out.println(Math.round(2.5));//3    round周围，四舍五入
    }

    @Test
    public void test5(){
        System.out.println(Math.ceil(-2.5));//-2.0  ceil天花板，向上取整
        System.out.println(Math.floor(-2.5));//-3.0  floor地板，向下取整
        System.out.println(Math.round(-2.5));//-2    round周围，四舍五入
    }

    @Test
    public void test6(){
        System.out.println(Math.round(-2.5));//-2    round周围，四舍五入
        System.out.println(Math.round(-2.4));//-2    round周围，四舍五入
        System.out.println(Math.round(-2.6));//-3    round周围，四舍五入

//        Math.round(x)   x+0.5 向下取整
        // -2.5 + 0.5 = -2  向下取整 -2
        // -2.4 + 0.5 = -1.9  向下取整 -2
        //-2.6 + 0.5 = -2.1  向下取整 -3
    }

    @Test
    public void test7(){
        System.out.println(Math.pow(2,5));//2的5次   32
        System.out.println(Math.pow(2.1, 3.5));//13.42046400464604

        System.out.println(Math.sqrt(9));//3

        System.out.println(Math.random());//[0,1)小数
        System.out.println("圆周率：" + Math.PI);

        System.out.println("最大值：" + Math.max(5,6));//6
        System.out.println("最小值：" + Math.min(5,6));//5
    }
}
